// This programs creates displays lanes that appear to be moving

#include<stdlib.h>
#include<curses.h>

void drawLanes(int laneSpeed, WINDOW *wnd);

int main(void)
{
        WINDOW *wnd;

        initscr();        // start incurses      

	wnd =newwin(0,0,0,0);		//wnd now points to, new fullscreen window
	drawLanes(110, wnd);		//call drawLanes with laneSpeed and wnd ptr
	endwin();
}

void drawLanes(int laneSpeed, WINDOW *wnd)		//draws moving lanes, speed Depends on laneSpeed varible
{
	//fast laneSpeed = 10
	//fastish laneSpeed = 110	
	//Medium  laneSpeed = 11000
	//Debug speed laneSpeed = 500000

	  int   maxcol,
                maxrow,
                row=0,
                col=0,
                rowTemp;

        getmaxyx(wnd, maxrow, maxcol);		//Gets the size of the window

        while(TRUE)
        {
                if (row >= maxrow)	
                {
                        row = rowTemp;
                        rowTemp-= 2;
                        if (rowTemp >= maxrow)
                        {
                                rowTemp = 0;
                        }

                }

                mvprintw(row, col, "|\n \n|\n");	//lane pattern
                row +=3;
                refresh();
		usleep(laneSpeed);		//lane speed
        }

}
